package com.zhu.controller;


import com.zhu.pojo.TransSum;
import com.zhu.service.ExpendService;
import com.zhu.service.IncomeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
public class SumController {
    @Autowired
    ExpendService expendService;
    @Autowired
    IncomeService incomeService;


    @CrossOrigin //解决跨域问题
    @PostMapping("/api/Count")
    public TransSum sum(@RequestBody TransSum tr) {
        TransSum result = new TransSum();

        TransSum s1 = expendService.summation(tr);
        TransSum s2 = incomeService.summation(tr);

//        result.setUserId(s1.getUserId());
        result.setExCount(s1.getExCount());
        result.setExSum(s1.getExSum());
        result.setInCount(s2.getInCount());
        result.setInSum(s2.getInSum());

//        System.out.println(result);


        return result;
    }


}

